// cloudfunctions/add-consultant/index.js
module.exports = {
  async main(event) {
    const db = uniCloud.database()
	//以下是兼容url访问的代码
	let body = event;
	if (event.body != undefined) {
		body = JSON.parse(event.body)
	}
	
    const { data } = body
    const res = await db.collection('consultants').add({
      ...data,
      create_date: Date.now()
    })
    return res
  }
}